import { cloneDeep, } from 'lodash-es';
import { userList } from "./user";

export let roleList: RoleRecord[] = [
  {createBy: null, createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "超级管理员", roleId: 1, roleName: "超级管理员", roleKey: "admin", roleSort: 1, dataScope: "1", menuCheckStrictly: true, deptCheckStrictly: true, status: "0", delFlag: "0", flag: false, menuIds: null, deptIds: null, permissions: null, admin: true},
  {createBy: null, createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "普通角色", roleId: 2, roleName: "普通角色", roleKey: "common", roleSort: 2, dataScope: "2", menuCheckStrictly: true, deptCheckStrictly: true, status: "1", delFlag: "0", flag: false, menuIds: null, deptIds: null, permissions: null, admin: false},
  {createBy: null, createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "普通角色", roleId: 3, roleName: "普通角色", roleKey: "common", roleSort: 2, dataScope: "2", menuCheckStrictly: true, deptCheckStrictly: true, status: "1", delFlag: "0", flag: false, menuIds: null, deptIds: null, permissions: null, admin: false},
  {createBy: null, createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "普通角色", roleId: 4, roleName: "普通角色", roleKey: "common", roleSort: 2, dataScope: "2", menuCheckStrictly: true, deptCheckStrictly: true, status: "0", delFlag: "0", flag: false, menuIds: null, deptIds: null, permissions: null, admin: false},
  {createBy: null, createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "普通角色", roleId: 5, roleName: "普通角色", roleKey: "common", roleSort: 2, dataScope: "2", menuCheckStrictly: true, deptCheckStrictly: true, status: "0", delFlag: "0", flag: false, menuIds: null, deptIds: null, permissions: null, admin: false},
  {createBy: null, createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "普通角色", roleId: 6, roleName: "普通角色", roleKey: "common", roleSort: 2, dataScope: "2", menuCheckStrictly: true, deptCheckStrictly: true, status: "1", delFlag: "0", flag: false, menuIds: null, deptIds: null, permissions: null, admin: false},
  {createBy: null, createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "普通角色", roleId: 7, roleName: "普通角色", roleKey: "common", roleSort: 2, dataScope: "2", menuCheckStrictly: true, deptCheckStrictly: true, status: "0", delFlag: "0", flag: false, menuIds: null, deptIds: null, permissions: null, admin: false},
  {createBy: null, createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "普通角色", roleId: 8, roleName: "普通角色", roleKey: "common", roleSort: 2, dataScope: "2", menuCheckStrictly: true, deptCheckStrictly: true, status: "1", delFlag: "0", flag: false, menuIds: null, deptIds: null, permissions: null, admin: false},
  {createBy: null, createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "普通角色", roleId: 9, roleName: "普通角色", roleKey: "common", roleSort: 2, dataScope: "2", menuCheckStrictly: true, deptCheckStrictly: true, status: "1", delFlag: "0", flag: false, menuIds: null, deptIds: null, permissions: null, admin: false},
  {createBy: null, createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "普通角色", roleId: 10, roleName: "普通角色", roleKey: "common", roleSort: 2, dataScope: "2", menuCheckStrictly: true, deptCheckStrictly: true, status: "0", delFlag: "0", flag: false, menuIds: null, deptIds: null, permissions: null, admin: false},
  {createBy: null, createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "普通角色", roleId: 11, roleName: "普通角色", roleKey: "common", roleSort: 2, dataScope: "2", menuCheckStrictly: true, deptCheckStrictly: true, status: "1", delFlag: "0", flag: false, menuIds: null, deptIds: null, permissions: null, admin: false},
  {createBy: null, createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "普通角色", roleId: 12, roleName: "普通角色", roleKey: "common", roleSort: 2, dataScope: "2", menuCheckStrictly: true, deptCheckStrictly: true, status: "0", delFlag: "0", flag: false, menuIds: null, deptIds: null, permissions: null, admin: false},
  {createBy: null, createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "普通角色", roleId: 13, roleName: "普通角色", roleKey: "common", roleSort: 2, dataScope: "2", menuCheckStrictly: true, deptCheckStrictly: true, status: "1", delFlag: "0", flag: false, menuIds: null, deptIds: null, permissions: null, admin: false},
  {createBy: null, createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "普通角色", roleId: 14, roleName: "普通角色", roleKey: "common", roleSort: 2, dataScope: "2", menuCheckStrictly: true, deptCheckStrictly: true, status: "1", delFlag: "0", flag: false, menuIds: null, deptIds: null, permissions: null, admin: false},
  {createBy: null, createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "普通角色", roleId: 15, roleName: "普通角色", roleKey: "common", roleSort: 2, dataScope: "2", menuCheckStrictly: true, deptCheckStrictly: true, status: "1", delFlag: "0", flag: false, menuIds: null, deptIds: null, permissions: null, admin: false},
  {createBy: null, createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "普通角色", roleId: 16, roleName: "普通角色", roleKey: "common", roleSort: 2, dataScope: "2", menuCheckStrictly: true, deptCheckStrictly: true, status: "0", delFlag: "0", flag: false, menuIds: null, deptIds: null, permissions: null, admin: false},
  {createBy: null, createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "普通角色", roleId: 17, roleName: "普通角色", roleKey: "common", roleSort: 2, dataScope: "2", menuCheckStrictly: true, deptCheckStrictly: true, status: "1", delFlag: "0", flag: false, menuIds: null, deptIds: null, permissions: null, admin: false},
  {createBy: null, createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "普通角色", roleId: 18, roleName: "普通角色", roleKey: "common", roleSort: 2, dataScope: "2", menuCheckStrictly: true, deptCheckStrictly: true, status: "0", delFlag: "0", flag: false, menuIds: null, deptIds: null, permissions: null, admin: false},
  {createBy: null, createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "普通角色", roleId: 19, roleName: "普通角色", roleKey: "common", roleSort: 2, dataScope: "2", menuCheckStrictly: true, deptCheckStrictly: true, status: "1", delFlag: "0", flag: false, menuIds: null, deptIds: null, permissions: null, admin: false},
  {createBy: null, createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "普通角色", roleId: 20, roleName: "普通角色", roleKey: "common", roleSort: 2, dataScope: "2", menuCheckStrictly: true, deptCheckStrictly: true, status: "0", delFlag: "0", flag: false, menuIds: null, deptIds: null, permissions: null, admin: false},
  {createBy: null, createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "普通角色", roleId: 21, roleName: "普通角色", roleKey: "common", roleSort: 2, dataScope: "2", menuCheckStrictly: true, deptCheckStrictly: true, status: "1", delFlag: "0", flag: false, menuIds: null, deptIds: null, permissions: null, admin: false},
  {createBy: null, createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "普通角色", roleId: 22, roleName: "普通角色", roleKey: "common", roleSort: 2, dataScope: "2", menuCheckStrictly: true, deptCheckStrictly: true, status: "0", delFlag: "0", flag: false, menuIds: null, deptIds: null, permissions: null, admin: false},
  {createBy: null, createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "普通角色", roleId: 23, roleName: "普通角色", roleKey: "common", roleSort: 2, dataScope: "2", menuCheckStrictly: true, deptCheckStrictly: true, status: "1", delFlag: "0", flag: false, menuIds: null, deptIds: null, permissions: null, admin: false},
  {createBy: null, createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "普通角色", roleId: 24, roleName: "普通角色", roleKey: "common", roleSort: 2, dataScope: "2", menuCheckStrictly: true, deptCheckStrictly: true, status: "0", delFlag: "0", flag: false, menuIds: null, deptIds: null, permissions: null, admin: false},
  {createBy: null, createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "普通角色", roleId: 25, roleName: "普通角色", roleKey: "common", roleSort: 2, dataScope: "2", menuCheckStrictly: true, deptCheckStrictly: true, status: "1", delFlag: "0", flag: false, menuIds: null, deptIds: null, permissions: null, admin: false},
  {createBy: null, createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "普通角色", roleId: 26, roleName: "普通角色", roleKey: "common", roleSort: 2, dataScope: "2", menuCheckStrictly: true, deptCheckStrictly: true, status: "1", delFlag: "0", flag: false, menuIds: null, deptIds: null, permissions: null, admin: false},
  {createBy: null, createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "普通角色", roleId: 27, roleName: "普通角色", roleKey: "common", roleSort: 2, dataScope: "2", menuCheckStrictly: true, deptCheckStrictly: true, status: "1", delFlag: "0", flag: false, menuIds: null, deptIds: null, permissions: null, admin: false},
  {createBy: null, createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "普通角色", roleId: 28, roleName: "普通角色", roleKey: "common", roleSort: 2, dataScope: "2", menuCheckStrictly: true, deptCheckStrictly: true, status: "0", delFlag: "0", flag: false, menuIds: null, deptIds: null, permissions: null, admin: false},
  {createBy: null, createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "普通角色", roleId: 29, roleName: "普通角色", roleKey: "common", roleSort: 2, dataScope: "2", menuCheckStrictly: true, deptCheckStrictly: true, status: "1", delFlag: "0", flag: false, menuIds: null, deptIds: null, permissions: null, admin: false},
  {createBy: null, createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "普通角色", roleId: 30, roleName: "普通角色", roleKey: "common", roleSort: 2, dataScope: "2", menuCheckStrictly: true, deptCheckStrictly: true, status: "0", delFlag: "0", flag: false, menuIds: null, deptIds: null, permissions: null, admin: false}

];

const mocks: MockRecord[] = [
  {
    method: "get",
    url: "/api/system/role/list",
    response(option) {
      const copyList = cloneDeep(roleList);

      const resList = copyList.splice((option.query.pageNum - 1) * option.query.pageSize, option.query.pageSize);

      let resData: responseType = {
        code: 200,
        msg: "查询成功",
        total: roleList.length,
        rows: resList,
      }
      return resData;
    }
  },
  {
    method: "get",
    url: "/api/system/role/:roleId",
    response(option) {
      const resRole = roleList.find(item => item.roleId == option.query.roleId);

      const resData: responseType = {
        code: resRole ? 200 : 500,
        msg: resRole ? "查询成功" : "查询失败",
        data: resRole,
      }
      return resData;
    }
  },
  {
    method: "post",
    url: "/api/system/role",
    response(option) {
      const newRole = option.body;
      newRole.roleId = roleList.length + 1;
      roleList.unshift(newRole);
      let resData: responseType = {
        code: 200,
        msg: "新增成功",
      }
      return resData;
    }
  },
  {
    method: "put",
    url: "/api/system/role",
    response(option) {
      const newRole = option.body;

      const index = roleList.findIndex(item => item.roleId == newRole.roleId);

      roleList.splice(index, 1, newRole);

      const resData: responseType = {
        code: 200,
        msg: "修改成功",
      }
      return resData;
    }
  },
  {
    method: "delete",
    url: "/api/system/role/:roleIds",
    response(option) {
      const roleIds = option.query.roleIds.split(',');

      const filterList = roleList.filter(item => !roleIds.includes(String(item.roleId)));

      roleList = filterList;

      const resData: responseType = {
        code: 200,
        msg: "删除成功",
      }
      return resData;
    }
  },
  {
    method: "get",
    url: "/api/system/menu/roleMenuTreeselect/:roleId",
    response(option) {
      const resRole = roleList.find(item => item.roleId == option.query.roleId);

      const resData: responseType = {
        code: resRole ? 200 : 500,
        msg: resRole ? "查询成功" : "查询失败",
        data: resRole,
        checkedKeys: [
          2000,
          2001,
          2002,
          2003,
          111,
          112,
          113,
          114,
          2005,
          2004,
          117,
          2006,
          2007,
          1000,
          1001,
          1002,
          1003,
          1004,
          1005,
          1006,
          1007,
          1008,
          1009,
          1010,
          1011,
          1012,
          1013,
          1014,
          1015,
          1016,
          1017,
          1018,
          1019,
          1020,
          1021,
          1022,
          1023,
          1024,
          1025,
          1026,
          1027,
          1028,
          1029,
          1030,
          1031,
          1032,
          1033,
          1034,
          1035,
          1036,
          1037,
          1038,
          1046,
          1047,
          1048,
          1049,
          1050,
          1051,
          1052,
          1053,
          1054,
          1055,
          1056,
          1057,
          1058,
          1059,
          1060,
          1039,
          1040,
          1041,
          1042,
          1043,
          1044,
          1045
        ],
        menus: [
          {
            "id": 1,
            "label": "系统管理",
            "children": [
              {
                "id": 100,
                "label": "用户管理",
                "children": [
                  {
                    "id": 1000,
                    "label": "用户查询"
                  },
                  {
                    "id": 1001,
                    "label": "用户新增"
                  },
                  {
                    "id": 1002,
                    "label": "用户修改"
                  },
                  {
                    "id": 1003,
                    "label": "用户删除"
                  },
                  {
                    "id": 1004,
                    "label": "用户导出"
                  },
                  {
                    "id": 1005,
                    "label": "用户导入"
                  },
                  {
                    "id": 1006,
                    "label": "重置密码"
                  }
                ]
              },
              {
                "id": 2000,
                "label": "分配角色"
              },
              {
                "id": 101,
                "label": "角色管理",
                "children": [
                  {
                    "id": 1007,
                    "label": "角色查询"
                  },
                  {
                    "id": 1008,
                    "label": "角色新增"
                  },
                  {
                    "id": 1009,
                    "label": "角色修改"
                  },
                  {
                    "id": 1010,
                    "label": "角色删除"
                  },
                  {
                    "id": 1011,
                    "label": "角色导出"
                  }
                ]
              },
              {
                "id": 2001,
                "label": "分配用户"
              },
              {
                "id": 102,
                "label": "菜单管理",
                "children": [
                  {
                    "id": 1012,
                    "label": "菜单查询"
                  },
                  {
                    "id": 1013,
                    "label": "菜单新增"
                  },
                  {
                    "id": 1014,
                    "label": "菜单修改"
                  },
                  {
                    "id": 1015,
                    "label": "菜单删除"
                  }
                ]
              },
              {
                "id": 103,
                "label": "部门管理",
                "children": [
                  {
                    "id": 1016,
                    "label": "部门查询"
                  },
                  {
                    "id": 1017,
                    "label": "部门新增"
                  },
                  {
                    "id": 1018,
                    "label": "部门修改"
                  },
                  {
                    "id": 1019,
                    "label": "部门删除"
                  }
                ]
              },
              {
                "id": 104,
                "label": "岗位管理",
                "children": [
                  {
                    "id": 1020,
                    "label": "岗位查询"
                  },
                  {
                    "id": 1021,
                    "label": "岗位新增"
                  },
                  {
                    "id": 1022,
                    "label": "岗位修改"
                  },
                  {
                    "id": 1023,
                    "label": "岗位删除"
                  },
                  {
                    "id": 1024,
                    "label": "岗位导出"
                  }
                ]
              },
              {
                "id": 105,
                "label": "字典管理",
                "children": [
                  {
                    "id": 1025,
                    "label": "字典查询"
                  },
                  {
                    "id": 1026,
                    "label": "字典新增"
                  },
                  {
                    "id": 1027,
                    "label": "字典修改"
                  },
                  {
                    "id": 1028,
                    "label": "字典删除"
                  },
                  {
                    "id": 1029,
                    "label": "字典导出"
                  }
                ]
              },
              {
                "id": 2002,
                "label": "字典值列表"
              },
              {
                "id": 106,
                "label": "参数设置",
                "children": [
                  {
                    "id": 1030,
                    "label": "参数查询"
                  },
                  {
                    "id": 1031,
                    "label": "参数新增"
                  },
                  {
                    "id": 1032,
                    "label": "参数修改"
                  },
                  {
                    "id": 1033,
                    "label": "参数删除"
                  },
                  {
                    "id": 1034,
                    "label": "参数导出"
                  }
                ]
              },
              {
                "id": 107,
                "label": "通知公告",
                "children": [
                  {
                    "id": 1035,
                    "label": "公告查询"
                  },
                  {
                    "id": 1036,
                    "label": "公告新增"
                  },
                  {
                    "id": 1037,
                    "label": "公告修改"
                  },
                  {
                    "id": 1038,
                    "label": "公告删除"
                  }
                ]
              },
              {
                "id": 2003,
                "label": "icon图标"
              }
            ]
          },
          {
            "id": 2,
            "label": "系统监控",
            "children": [
              {
                "id": 108,
                "label": "日志管理",
                "children": [
                  {
                    "id": 500,
                    "label": "操作日志",
                    "children": [
                      {
                        "id": 1039,
                        "label": "操作查询"
                      },
                      {
                        "id": 1040,
                        "label": "操作删除"
                      },
                      {
                        "id": 1041,
                        "label": "日志导出"
                      }
                    ]
                  },
                  {
                    "id": 501,
                    "label": "登录日志",
                    "children": [
                      {
                        "id": 1042,
                        "label": "登录查询"
                      },
                      {
                        "id": 1043,
                        "label": "登录删除"
                      },
                      {
                        "id": 1044,
                        "label": "日志导出"
                      },
                      {
                        "id": 1045,
                        "label": "账户解锁"
                      }
                    ]
                  }
                ]
              },
              {
                "id": 109,
                "label": "在线用户",
                "children": [
                  {
                    "id": 1046,
                    "label": "在线查询"
                  },
                  {
                    "id": 1047,
                    "label": "批量强退"
                  },
                  {
                    "id": 1048,
                    "label": "单条强退"
                  }
                ]
              },
              {
                "id": 110,
                "label": "定时任务",
                "children": [
                  {
                    "id": 1049,
                    "label": "任务查询"
                  },
                  {
                    "id": 1050,
                    "label": "任务新增"
                  },
                  {
                    "id": 1051,
                    "label": "任务修改"
                  },
                  {
                    "id": 1052,
                    "label": "任务删除"
                  },
                  {
                    "id": 1053,
                    "label": "状态修改"
                  },
                  {
                    "id": 1054,
                    "label": "任务导出"
                  }
                ]
              },
              {
                "id": 111,
                "label": "数据监控"
              },
              {
                "id": 112,
                "label": "服务监控"
              },
              {
                "id": 113,
                "label": "缓存监控"
              },
              {
                "id": 114,
                "label": "缓存列表"
              }
            ]
          },
          {
            "id": 3,
            "label": "系统工具",
            "children": [
              {
                "id": 116,
                "label": "代码生成",
                "children": [
                  {
                    "id": 1055,
                    "label": "生成查询"
                  },
                  {
                    "id": 1056,
                    "label": "生成修改"
                  },
                  {
                    "id": 1057,
                    "label": "生成删除"
                  },
                  {
                    "id": 1058,
                    "label": "导入代码"
                  },
                  {
                    "id": 1059,
                    "label": "预览代码"
                  },
                  {
                    "id": 1060,
                    "label": "生成代码"
                  }
                ]
              },
              {
                "id": 2004,
                "label": "代码生成配置"
              },
              {
                "id": 2005,
                "label": "生成 代码详情"
              },
              {
                "id": 117,
                "label": "系统接口"
              },
              {
                "id": 2006,
                "label": "前端代码生成"
              },
              {
                "id": 2007,
                "label": "前端代码生成详情"
              }
            ]
          }
        ],
      }
      return resData;
    }
  },
  {
    method: "get",
    url: "/api/system/role/deptTree/:roleId",
    response(option) {
      const resRole = roleList.find(item => item.roleId == option.query.roleId);

      const resData: responseType = {
        code: resRole ? 200 : 500,
        msg: resRole ? "查询成功" : "查询失败",
        data: resRole,
        checkedKeys: [
          2000,
          2001,
          2002,
          2003,
          111,
          112,
          113,
          114,
          2005,
          2004,
          117,
          2006,
          2007,
          1000,
          1001,
          1002,
          1003,
          1004,
          1005,
          1006,
          1007,
          1008,
          1009,
          1010,
          1011,
          1012,
          1013,
          1014,
          1015,
          1016,
          1017,
          1018,
          1019,
          1020,
          1021,
          1022,
          1023,
          1024,
          1025,
          1026,
          1027,
          1028,
          1029,
          1030,
          1031,
          1032,
          1033,
          1034,
          1035,
          1036,
          1037,
          1038,
          1046,
          1047,
          1048,
          1049,
          1050,
          1051,
          1052,
          1053,
          1054,
          1055,
          1056,
          1057,
          1058,
          1059,
          1060,
          1039,
          1040,
          1041,
          1042,
          1043,
          1044,
          1045
        ],
        depts: [
          {
            "id": 1,
            "label": "系统管理",
            "children": [
              {
                "id": 100,
                "label": "用户管理",
                "children": [
                  {
                    "id": 1000,
                    "label": "用户查询"
                  },
                  {
                    "id": 1001,
                    "label": "用户新增"
                  },
                  {
                    "id": 1002,
                    "label": "用户修改"
                  },
                  {
                    "id": 1003,
                    "label": "用户删除"
                  },
                  {
                    "id": 1004,
                    "label": "用户导出"
                  },
                  {
                    "id": 1005,
                    "label": "用户导入"
                  },
                  {
                    "id": 1006,
                    "label": "重置密码"
                  }
                ]
              },
              {
                "id": 2000,
                "label": "分配角色"
              },
              {
                "id": 101,
                "label": "角色管理",
                "children": [
                  {
                    "id": 1007,
                    "label": "角色查询"
                  },
                  {
                    "id": 1008,
                    "label": "角色新增"
                  },
                  {
                    "id": 1009,
                    "label": "角色修改"
                  },
                  {
                    "id": 1010,
                    "label": "角色删除"
                  },
                  {
                    "id": 1011,
                    "label": "角色导出"
                  }
                ]
              },
              {
                "id": 2001,
                "label": "分配用户"
              },
              {
                "id": 102,
                "label": "菜单管理",
                "children": [
                  {
                    "id": 1012,
                    "label": "菜单查询"
                  },
                  {
                    "id": 1013,
                    "label": "菜单新增"
                  },
                  {
                    "id": 1014,
                    "label": "菜单修改"
                  },
                  {
                    "id": 1015,
                    "label": "菜单删除"
                  }
                ]
              },
              {
                "id": 103,
                "label": "部门管理",
                "children": [
                  {
                    "id": 1016,
                    "label": "部门查询"
                  },
                  {
                    "id": 1017,
                    "label": "部门新增"
                  },
                  {
                    "id": 1018,
                    "label": "部门修改"
                  },
                  {
                    "id": 1019,
                    "label": "部门删除"
                  }
                ]
              },
              {
                "id": 104,
                "label": "岗位管理",
                "children": [
                  {
                    "id": 1020,
                    "label": "岗位查询"
                  },
                  {
                    "id": 1021,
                    "label": "岗位新增"
                  },
                  {
                    "id": 1022,
                    "label": "岗位修改"
                  },
                  {
                    "id": 1023,
                    "label": "岗位删除"
                  },
                  {
                    "id": 1024,
                    "label": "岗位导出"
                  }
                ]
              },
              {
                "id": 105,
                "label": "字典管理",
                "children": [
                  {
                    "id": 1025,
                    "label": "字典查询"
                  },
                  {
                    "id": 1026,
                    "label": "字典新增"
                  },
                  {
                    "id": 1027,
                    "label": "字典修改"
                  },
                  {
                    "id": 1028,
                    "label": "字典删除"
                  },
                  {
                    "id": 1029,
                    "label": "字典导出"
                  }
                ]
              },
              {
                "id": 2002,
                "label": "字典值列表"
              },
              {
                "id": 106,
                "label": "参数设置",
                "children": [
                  {
                    "id": 1030,
                    "label": "参数查询"
                  },
                  {
                    "id": 1031,
                    "label": "参数新增"
                  },
                  {
                    "id": 1032,
                    "label": "参数修改"
                  },
                  {
                    "id": 1033,
                    "label": "参数删除"
                  },
                  {
                    "id": 1034,
                    "label": "参数导出"
                  }
                ]
              },
              {
                "id": 107,
                "label": "通知公告",
                "children": [
                  {
                    "id": 1035,
                    "label": "公告查询"
                  },
                  {
                    "id": 1036,
                    "label": "公告新增"
                  },
                  {
                    "id": 1037,
                    "label": "公告修改"
                  },
                  {
                    "id": 1038,
                    "label": "公告删除"
                  }
                ]
              },
              {
                "id": 2003,
                "label": "icon图标"
              }
            ]
          },
          {
            "id": 2,
            "label": "系统监控",
            "children": [
              {
                "id": 108,
                "label": "日志管理",
                "children": [
                  {
                    "id": 500,
                    "label": "操作日志",
                    "children": [
                      {
                        "id": 1039,
                        "label": "操作查询"
                      },
                      {
                        "id": 1040,
                        "label": "操作删除"
                      },
                      {
                        "id": 1041,
                        "label": "日志导出"
                      }
                    ]
                  },
                  {
                    "id": 501,
                    "label": "登录日志",
                    "children": [
                      {
                        "id": 1042,
                        "label": "登录查询"
                      },
                      {
                        "id": 1043,
                        "label": "登录删除"
                      },
                      {
                        "id": 1044,
                        "label": "日志导出"
                      },
                      {
                        "id": 1045,
                        "label": "账户解锁"
                      }
                    ]
                  }
                ]
              },
              {
                "id": 109,
                "label": "在线用户",
                "children": [
                  {
                    "id": 1046,
                    "label": "在线查询"
                  },
                  {
                    "id": 1047,
                    "label": "批量强退"
                  },
                  {
                    "id": 1048,
                    "label": "单条强退"
                  }
                ]
              },
              {
                "id": 110,
                "label": "定时任务",
                "children": [
                  {
                    "id": 1049,
                    "label": "任务查询"
                  },
                  {
                    "id": 1050,
                    "label": "任务新增"
                  },
                  {
                    "id": 1051,
                    "label": "任务修改"
                  },
                  {
                    "id": 1052,
                    "label": "任务删除"
                  },
                  {
                    "id": 1053,
                    "label": "状态修改"
                  },
                  {
                    "id": 1054,
                    "label": "任务导出"
                  }
                ]
              },
              {
                "id": 111,
                "label": "数据监控"
              },
              {
                "id": 112,
                "label": "服务监控"
              },
              {
                "id": 113,
                "label": "缓存监控"
              },
              {
                "id": 114,
                "label": "缓存列表"
              }
            ]
          },
          {
            "id": 3,
            "label": "系统工具",
            "children": [
              {
                "id": 116,
                "label": "代码生成",
                "children": [
                  {
                    "id": 1055,
                    "label": "生成查询"
                  },
                  {
                    "id": 1056,
                    "label": "生成修改"
                  },
                  {
                    "id": 1057,
                    "label": "生成删除"
                  },
                  {
                    "id": 1058,
                    "label": "导入代码"
                  },
                  {
                    "id": 1059,
                    "label": "预览代码"
                  },
                  {
                    "id": 1060,
                    "label": "生成代码"
                  }
                ]
              },
              {
                "id": 2004,
                "label": "代码生成配置"
              },
              {
                "id": 2005,
                "label": "生成 代码详情"
              },
              {
                "id": 117,
                "label": "系统接口"
              },
              {
                "id": 2006,
                "label": "前端代码生成"
              },
              {
                "id": 2007,
                "label": "前端代码生成详情"
              }
            ]
          }
        ],
      }
      return resData;
    }
  },
  {
    method: "get",
    url: "/api/system/role/authUser/allocatedList",
    response(option) {
      const resRole = roleList.find(item => item.roleId == option.query.roleId);

      const userIds = resRole.userIds || [];

      const filterUserList = userList.filter(item => userIds.includes(item.userId));

      const copyUsetList = cloneDeep(filterUserList);

      const resList = copyUsetList.splice((option.query.pageNum - 1) * option.query.pageSize, option.query.pageSize);

      const resData: responseType = {
        code: 200,
        msg: "查询成功",
        total: filterUserList.length,
        rows: resList,
      }
      return resData;
    }
  },
  {
    method: "get",
    url: "/api/system/role/authUser/unallocatedList",
    response(option) {
      const resRole = roleList.find(item => item.roleId == option.query.roleId);

      const userIds = resRole.userIds || [];

      const filterUserList = userList.filter(item => !userIds.includes(item.userId));

      const copyUsetList = cloneDeep(filterUserList);

      const resList = copyUsetList.splice((option.query.pageNum - 1) * option.query.pageSize, option.query.pageSize);

      const resData: responseType = {
        code: 200,
        msg: "查询成功",
        total: filterUserList.length,
        rows: resList,
      }
      return resData;
    }
  },
  {
    method: "put",
    url: "/api/system/role/authUser/selectAll",
    response(option) {

      const newRole = roleList.find(item => item.roleId == option.query.roleId);

      const userIdArr = option.query.userIds?.split(',') || []

      const userIds = userIdArr.map(item => Number(item));

      if(!newRole.userIds) {
        newRole.userIds = []
      }

      newRole.userIds.push(...userIds);

      const resData: responseType = {
        code: 200,
        msg: "修改成功",
      }
      return resData;
    }
  },
  {
    method: "put",
    url: "/api/system/role/authUser/cancelAll",
    response(option) {
      const newRole = roleList.find(item => item.roleId == option.query.roleId);

      const newUserIds = (option.query.userIds?.split(',') || []).map(item => Number(item));

      if(!newRole.userIds) {
        newRole.userIds = [];
      }

      const newUserList = newRole.userIds.filter(item => !newUserIds.includes(item));

      newRole.userIds = newUserList;

      const resData: responseType = {
        code: 200,
        msg: "修改成功",
      }
      return resData;
    }
  },
]

export default mocks